
#include <cassert>
#include <iostream>

using namespace std;

void setToVal(int *&p, int val) { p = new int{val}; }

int main() {
  int *p = new int{4};
  int *&rp = p;
  cout << *p << endl;
  *rp = 100;
  cout << *p << endl;
  cout << p << endl;
  rp = new int{5};
  cout << p << endl;
  cout << *p << endl;

  int *tmp;
  setToVal(tmp, 199);
  cout << *tmp << endl;
  return 0;
}